﻿using System;

namespace InfiniTec
{
	public static class DateTimeExtension
	{
		public static DateTime ToTimeZone(this DateTime value, TimeZoneInfo timeZone)
		{
			if (timeZone == null) throw new ArgumentNullException("timeZone");

			return TimeZoneInfo.ConvertTime(value, timeZone);
		}

		public static DateTime ToTimeZone(this DateTime value, TimeZoneInfo sourceTimeZone, TimeZoneInfo destinationTimeZone)
		{
			if (sourceTimeZone == null) throw new ArgumentNullException("sourceTimeZone");
			if (destinationTimeZone == null) throw new ArgumentNullException("destinationTimeZone");

			return TimeZoneInfo.ConvertTime(value, sourceTimeZone, destinationTimeZone);
		}
	}
}
